package utils
{
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.net.URLRequest;
	
	/**
	 * 图片组件 
	 * @author PC-100
	 * 
	 */	
	public class Image extends Sprite{
		public function Image(){
			super();
		}
		
		/**
		 * 加载图片的loader 
		 */		
		private var loader:Loader;
		/**
		 * 图片路径 
		 */		
		private var _source:String;
		
		
		public function get source():String{
			return _source;
		}

		public function set source(value:String):void{
			_source = value;
			loadImage();
		}
		/**
		 * 加载图片 
		 * 
		 */
		private function loadImage():void{
			if( loader == null ){
				loader = new Loader();
				addChild( loader );
			}
			loader.load( new URLRequest( source ) );
			
			x = -1*loader.width;
			y = -1*loader.height;
		}
	}
	
	
}